import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.script.Skills;
import com.speljohan.rsbot.script.wrappers.RSObject;
import com.speljohan.rsbot.script.wrappers.RSTile;
import com.speljohan.rsbot.script.wrappers.RSTilePath;

public class ironBANKER extends Script {
	public static final int MINING_STAT = Skills.getStatIndex("Mining");

	public static final int[] Rock = new int[] { 11954, 11955, 11956 };
	private final long StartTime = System.currentTimeMillis();
	private int State = 0;
	public int orecount = 0;
	public int[] pickaxeID = { 1265, 1267, 1296, 1273, 1271, 1275 };
	public RSTile[] BankToRocksTiles = { new RSTile(3284, 3370),
			new RSTile(3292, 3385), new RSTile(3291, 3400),
			new RSTile(3286, 3416), new RSTile(3276, 3428),
			new RSTile(3261, 3428), new RSTile(3253, 3421) };
	private final RSTilePath BankToRocks = new RSTilePath(BankToRocksTiles,
			this);

	public RSTilePath RocksToBank = new RSTilePath(
			reversePath(BankToRocksTiles), this);

	public ironBANKER() {
		setParameter("name", "ironBANKER");
		setParameter("version", 1);
		setParameter("author", "Austin");
		setParameter("category", "Mining");
		setParameter(
				"description",
				"<html>\n"
						+ "<head></head>\n"
						+ "<body>\n"
						+ "<center>"
						+ "<h2>"
						+ getName()
						+ "</h2>"
						+ "</center>\n"
						+ "<p\n"
						+ "<b>Author:</b> "
						+ getAuthor()
						+ "<p>\n"
						+ "<b>Version:</b> "
						+ getVersion()
						+ "<p>\n"
						+ "Iron miner, and banker."
						+ "<p>\n"
						+ "<b>Features:</b>"
						+ "<ul><li>Mines iron ore at Varrock East Mine, and banks.</li>"
						+ "</body>\n" + "</html>");
	}

	@SuppressWarnings("deprecation")
	@Override
	public int loop() {
		try {
			switch (State) {
			case 0:
				if (getInventoryCount() == 28) {
					State++;
				} else {
					if (getInventoryCount() <= 1) {
						BankToRocks.walkToStart();
					}
					final RSObject Rocks = findObject(ironBANKER.Rock);
					if (Rocks != null && getMyPlayer().getAnimation() == -1
							&& !getMyPlayer().isMoving()) {
						atObject(Rocks, "Mine");
					}
				}
				break;
			case 1:
				RocksToBank.walkToStart();
				final RSObject Bankobj = findObject(11402);
				atObject(Bankobj, "Use-quickly");
				if (bank.getInterface().isValid()) {
					depositAllExcept(pickaxeID);
					orecount++;
				}
				log
						.info("/Time Running: "
								+ Math
										.round((System.currentTimeMillis() - StartTime) / 216000)
								+ " minutes");
				log.info("Mined " + orecount + " loads.");
				log.info("Mined " + orecount * 27 + " ore");
				log.info("Mining level is: "
						+ Integer.toString(skills
								.getCurrentSkillLevel(ironBANKER.MINING_STAT)));
				State = 0;
				break;
			}

		} catch (final Exception e) {
			e.printStackTrace();
		}
		return random(1000, 2000);
	}

	@Override
	public boolean onStart(final String[] args) {
		return true;
	}
}